﻿using GPS.COMMON;
using GPS.DataAccessLayer;
using GPS.ENTITYS;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace GPS.GPS_DAL
{
    public class GPS_CanhBaoDAO
    {
        public List<ViewModelDPT_HETHAN_GIAYPHEP> GPS_CANHBAO_PT(string pDVGTVT_MA)
        {
            DbContextHelper<GPS_NVContext> _db = Singleton<DbContextHelper<GPS_NVContext>>.Inst;

            var _pDVGTVT_MA = new OracleParameter("pDVGTVT_MA", OracleDbType.Varchar2, (pDVGTVT_MA == null ? DBNull.Value : (object)pDVGTVT_MA), ParameterDirection.Input);

            var _pRET = new OracleParameter("pRET", OracleDbType.RefCursor, ParameterDirection.Output);
            var datas = _db.DbContext.Database.SqlQuery<ViewModelDPT_HETHAN_GIAYPHEP>(@"BEGIN GPS_CANHBAO.GPS_CANHBAO_PT(:pDVGTVT_MA
                                                                                                           ,:pRET); END;"
                                                                                          , _pDVGTVT_MA
                                                                                          , _pRET
                                                                                        ).ToList();
            return datas;
        }

        public List<ViewModelDCSDT_HETHAN_GIAYPHEP> GPS_CANHBAO_CSDT(string pDVGTVT_MA)
        {
            DbContextHelper<GPS_NVContext> _db = Singleton<DbContextHelper<GPS_NVContext>>.Inst;

            var _pDVGTVT_MA = new OracleParameter("pDVGTVT_MA", OracleDbType.Varchar2, (pDVGTVT_MA == null ? DBNull.Value : (object)pDVGTVT_MA), ParameterDirection.Input);

            var _pRET = new OracleParameter("pRET", OracleDbType.RefCursor, ParameterDirection.Output);
            var datas = _db.DbContext.Database.SqlQuery<ViewModelDCSDT_HETHAN_GIAYPHEP>(@"BEGIN GPS_CANHBAO.GPS_CANHBAO_CSDT(:pDVGTVT_MA
                                                                                                           ,:pRET); END;"
                                                                                          , _pDVGTVT_MA
                                                                                          , _pRET
                                                                                        ).ToList();
            return datas;
        }

        public List<ViewModelDGV_TRUNG_CMT> GPS_CANHBAO_GV_DUP_CMT()
        {
            DbContextHelper<GPS_NVContext> _db = Singleton<DbContextHelper<GPS_NVContext>>.Inst;

            var _pRET = new OracleParameter("pRET", OracleDbType.RefCursor, ParameterDirection.Output);
            var datas = _db.DbContext.Database.SqlQuery<ViewModelDGV_TRUNG_CMT>(@"BEGIN GPS_CANHBAO.GPS_CANHBAO_GV_DUP_CMT(:pRET); END;"
                                                                                          , _pRET
                                                                                        ).ToList();
            return datas;
        }

        public List<ViewModelDPT_TRUNG_BIENSO> GPS_CANHBAO_PT_DUP_BIENSO()
        {
            DbContextHelper<GPS_NVContext> _db = Singleton<DbContextHelper<GPS_NVContext>>.Inst;

            var _pRET = new OracleParameter("pRET", OracleDbType.RefCursor, ParameterDirection.Output);
            var datas = _db.DbContext.Database.SqlQuery<ViewModelDPT_TRUNG_BIENSO>(@"BEGIN GPS_CANHBAO.GPS_CANHBAO_PT_DUP_BIENSO(:pRET); END;"
                                                                                          , _pRET
                                                                                        ).ToList();
            return datas;
        }
    }
}